#ifndef BALL_H
#define BALL_H

#include <QGraphicsItem>
#include <QGraphicsSceneMouseEvent>
#include "field.h"

class Field;

class Ball : public QGraphicsItem
{

public:
    Ball(int x, int y, int row, int col, int d, Field *field);

    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
    QPainterPath shape() const;
    QRectF boundingRect() const;

    enum { Type = UserType + 2 };

    int type() const
    {
        // Enable the use of qgraphicsitem_cast with this item.
        return Type;
    }
private:
    int d;
    Field *field;
    QPointF lastPos;
    int lastRow;
    int lastCol;

protected:
    void mousePressEvent(QGraphicsSceneMouseEvent *event);
    void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
};

#endif // BALL_H
